package com.techfort.affs;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class StoredAccountAdapter {

	private Context context;
	private SQLiteDatabase database;
	private StoredAccountHelper dbHelper;
	
	public StoredAccountAdapter(Context context){
		this.context = context;
	}
	
	public StoredAccountAdapter open(){
		dbHelper = new StoredAccountHelper(context);
		database = dbHelper.getWritableDatabase();
		return this;
	}
	
	public void close(){
		dbHelper.close();
	}
	
	public String getAccount(){
		
		Cursor cursor = database.query("affs_account", new String [] {"email"}, null, null, null, null, null);
		cursor.moveToFirst();
		String account = cursor.getString(0);
		cursor.close();
		return account;
		
	}
	
	public void updateAccount(String value){
		ContentValues values = new ContentValues();
		values.put("email", value);
		database.update("affs_account", values, null, null);
	}
	
}
